import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';

import { DashboardComponent } from './dashboard/dashboard.component';
// import { HeroDetailComponent } from './heroes/hero-detail/hero-detail.component';
// import { ContactComponent } from './contact/contact.component';
// import { WikiComponent } from './wiki/wiki.component';
import { PageNotFoundComponent } from './not-found.component';
import { ComposeMessageComponent } from './core/compose-message/compose-message.component';

import { CanDeactivateGuard } from './can-deactivate-guard.service';
import { AuthGuard } from './auth-guard.service';
import { SelectivePreloadingStrategy } from './selective-preloading-strategy';

const appRoutes: Routes = [

  // { path: 'detail/:id', component: HeroDetailComponent },
  {
    path: 'compose',
    component: ComposeMessageComponent,
    outlet: 'popup'
  },
  { path: 'heroes', loadChildren: 'app/heroes/hero.module#HeroModule' },
  {
    path: 'crisis',
    loadChildren: 'app/crisis/crisis.module#CrisisModule'
  },
  {
    path: 'dashboard',
    component: DashboardComponent
  },
  // { path: 'wiki', component: WikiComponent },
  {
    path: 'admin',
    loadChildren: 'app/admin/admin.module#AdminModule',
    canLoad: [AuthGuard]
  },
  { path: 'contact', loadChildren: 'app/contact/contact.module#ContactModule' },
  { path: '', redirectTo: '/dashboard', pathMatch: 'full' },
  { path: '**', component: PageNotFoundComponent }
];

@NgModule({
  imports: [
    RouterModule.forRoot(
      appRoutes,
      { preloadingStrategy: SelectivePreloadingStrategy }
    )],
  exports: [RouterModule],
  providers: [CanDeactivateGuard, SelectivePreloadingStrategy],
})
export class AppRoutingModule { }
